<?php

namespace privateClass\App;

class Query {
	public static function parse($_request_method) {
		
		$result = FALSE;
		$tmp_uri = explode('&',$_SERVER['QUERY_STRING'],2);
		if (!isset($tmp_uri[1])) {
			$result['query_uri'] = '';
		} else {
			$retval = explode('|',$tmp_uri[1]);
			$result['query_uri'] = $retval[0] == '' ? '' : urldecode($retval[0]);
			isset($retval[1]) ? parse_str($retval[1],$result['query_settings']) : FALSE ;
		}
		
		switch (strtoupper($_request_method)) {
			case 'POST' :
				$result['method'] = _HTTP_POST;
				break;
			case 'PUT' :
				$result['method'] = _HTTP_PUT;
				break;
			case 'DELETE' :
				$result['method'] = _HTTP_DELETE;
				break;
			case 'GET' :
			default:
				$result['method'] = _HTTP_GET;
				break;
		}
		
		//初始化参数
		//获取client_id
		isset($result['query_settings']['AMSCID']) ? TRUE : $result['query_settings']['AMSCID'] = NULL;
		
		return $result;
	}
	
}

?>